From 6791754b3caa710702042f510aeb054c71fc7390 Mon Sep 17 00:00:00 2001 From: robertl Date: Sun, 6 Apr 2008 04:36:38 +0000 Subject: [PATCH] CSV: if date is before 1/1/1970, don't crash on Windows. --- csv_util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/csv_util.c b/csv_util.c index 14c1e5040..5b662743d 100644 --- a/csv_util.c +++ b/csv_util.c @@ -848,13 +848,16 @@ static int writehms(char * buff, size_t bufsize, const char * format, time_t t, int gmt ) { - static struct tm * stmp; + static struct tm no_time = {0}; + static struct tm * stmp = &no_time; if (gmt) stmp = gmtime(&t); else stmp = localtime(&t); + if (stmp == NULL) stmp = &no_time; + return snprintf(buff, bufsize, format, stmp->tm_hour, stmp->tm_min, stmp->tm_sec, (stmp->tm_hour>=12?"PM":"AM") ); -- 2.30.2